#include "special_setting.h"
#include "ui_special_setting.h"
#include <QProcess>
special_setting::special_setting(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::special_setting)
{
    ui->setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint);
    if(whole_machine_parameter.limits_unlock)
    {
        ui->limits_unlock_btn->setText(trUtf8("权限加锁"));
           }
    else{
        ui->limits_unlock_btn->setText(trUtf8("权限解锁"));
        }

    machine_type_selection=NULL;
}

special_setting::~special_setting()
{
    delete ui;
}

void special_setting::on_record_factory_time_btn_clicked()
{
    BUTTON_SOUND;
    if( Affirm("确认是否初始化？"))
     {
    ui->record_factory_time_btn->SET_COLOR_RED
    whole_machine_parameter.str_factory_time=QDate::currentDate().toString("yyyy.MM.dd");
    whole_machine_parameter.used_times_counter=0;
    config_changed=true;
    }
}

void special_setting::on_limits_unlock_btn_clicked()
{
 BUTTON_SOUND;
 if( Affirm("确认是否管理权限？"))
  {
 if(whole_machine_parameter.limits_unlock){
     whole_machine_parameter.limits_unlock=0;
     ui->limits_unlock_btn->SET_COLOR_GREEN
     ui->limits_unlock_btn->setText(trUtf8("权限解锁"));
        }
 else{
 whole_machine_parameter.limits_unlock=1;
 ui->limits_unlock_btn->SET_COLOR_RED
 ui->limits_unlock_btn->setText(trUtf8("权限已解"));
 }
    config_changed=true;
 }
}


void special_setting::on_machine_type_btn_clicked()
{
    BUTTON_SOUND
    if(machine_type_selection==NULL) machine_type_selection=new machine_type;
    machine_type_selection->entrance();
}

void special_setting::on_return_btn_clicked()
{   BUTTON_SOUND;
    close();
}


void special_setting::on_serial_number_btn_clicked()
{
  BUTTON_SOUND;
  if( Affirm("确认是否输入产品编号？") )
  {
  input->cancel_password_mode();
  QObject:: connect(  input->ui->enter, SIGNAL(clicked()),input, SLOT(accept()) );
  input->exec();
  disconnect( input->ui->enter, SIGNAL(clicked()),input,SLOT(accept()));
  if(input->enter)
 {
  whole_machine_parameter.serial_number=input->textword;
  //manager->ui->serial_number_label->setText(serial_number);
//  emit value_changed();
  }
  }
}

void special_setting::on_setIO_btn_clicked()
{
    BUTTON_SOUND;
    MCD_Interface->set_datamap(&IO_setting_datamap,4);
    MCD_Interface->showFullScreen();

}
